package com.xc.controller;

import com.xc.common.ServerResponse;
import com.xc.service.ISiteArticleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;

/**
 * @author mipha
 * @version 1.0
 * @date 2019/3/20 12:13 PM
 */
@Controller
@RequestMapping("/api/art/")
@Slf4j
public class ArticleApiController {

    @Autowired
    ISiteArticleService iSiteArticleService;


    /**
     *  前端查询新闻的列表
     * @param artTitle
     * @param artType
     * @param pageNum
     * @param pageSize
     * @return
     */
    @RequestMapping("list.do")
    @ResponseBody
    public ServerResponse list(@RequestParam(value = "artTitle", required = false) String artTitle
            , @RequestParam(value = "artType", required = false) String artType
            , @RequestParam(value = "pageNum", defaultValue = "1") int pageNum
            , @RequestParam(value = "pageSize", defaultValue = "12") int pageSize){
        return iSiteArticleService.list(artTitle,artType,pageNum,pageSize);
    }

    /**
     *  详情
     * @param artId
     * @return
     */
    @RequestMapping("detail.do")
    @ResponseBody
    public ServerResponse detail(Integer artId){
        return iSiteArticleService.detail(artId);
    }


}
